#!/bin/sh
patch -p0 < $0
exit 0
Index: compiler/lib/Transforms/IPO/GlobalOpt.cpp
===================================================================
--- compiler/lib/Transforms/IPO/GlobalOpt.cpp	(LLVM 3.5)
+++ compiler/lib/Transforms/IPO/GlobalOpt.cpp	(working copy)
@@ -497,6 +497,7 @@
                                                In, GV->getName()+"."+Twine(i),
                                                GV->getThreadLocalMode(),
                                               GV->getType()->getAddressSpace());
+      NGV->copyAttributesFrom(GV);
       Globals.insert(GV, NGV);
       NewGlobals.push_back(NGV);
 
@@ -530,6 +531,7 @@
                                                In, GV->getName()+"."+Twine(i),
                                                GV->getThreadLocalMode(),
                                               GV->getType()->getAddressSpace());
+      NGV->copyAttributesFrom(GV);
       Globals.insert(GV, NGV);
       NewGlobals.push_back(NGV);
 
@@ -845,6 +847,7 @@
                                              GV->getName()+".body",
                                              GV,
                                              GV->getThreadLocalMode());
+  NewGV->copyAttributesFrom(GV);
 
   // If there are bitcast users of the malloc (which is typical, usually we have
   // a malloc + bitcast) then replace them with uses of the new global.  Update
@@ -878,6 +881,7 @@
                        GlobalValue::InternalLinkage,
                        ConstantInt::getFalse(GV->getContext()),
                        GV->getName()+".init", GV->getThreadLocalMode());
+  InitBool->copyAttributesFrom(GV);
   bool InitBoolUsed = false;
 
   // Loop over all uses of GV, processing them in turn.
@@ -1300,6 +1304,7 @@
                          Constant::getNullValue(PFieldTy),
                          GV->getName() + ".f" + Twine(FieldNo), GV,
                          GV->getThreadLocalMode());
+    NGV->copyAttributesFrom(GV);
     FieldGlobals.push_back(NGV);
 
     unsigned TypeSize = DL->getTypeAllocSize(FieldTy);
@@ -1627,6 +1632,7 @@
                                              GV->getName()+".b",
                                              GV->getThreadLocalMode(),
                                              GV->getType()->getAddressSpace());
+  NewGV->copyAttributesFrom(GV);
   GV->getParent()->getGlobalList().insert(GV, NewGV);
 
   Constant *InitVal = GV->getInitializer();
@@ -2739,6 +2745,7 @@
   GlobalVariable *NV =
       new GlobalVariable(*M, ATy, false, llvm::GlobalValue::AppendingLinkage,
                          llvm::ConstantArray::get(ATy, UsedArray), "");
+  NV->copyAttributesFrom(&V);
   NV->takeName(&V);
   NV->setSection("llvm.metadata");
   delete &V;
